unit uniDtmSisnnovi;

interface

uses
  SysUtils, Classes, DB, ADODB;

type
  TdtmSisnnovi = class(TDataModule)
    connSisnnovi: TADOConnection;
    QR_TEMP: TADOQuery;
  private
    { Private declarations }
  public
    procedure ExecuteQUERY(const SQLCode: String;AParams: TParameters = nil);
    function  NewQuery(const SQLCode: String; AParams: TParameters = nil;parAutoOpen: Boolean = True) : TADOQuery;
  end;

var
  dtmSisnnovi: TdtmSisnnovi;

implementation

{$R *.dfm}

{ TdtmSisnnovi }

procedure TdtmSisnnovi.ExecuteQUERY(const SQLCode: String;
  AParams: TParameters);
var
  qryTemp: TADOQuery;
begin
  qryTemp := NewQuery(SQLCode,AParams,False);
  try
    qryTemp.ExecSql;
  finally
    qryTemp.Free;
  end;
end;

function TdtmSisnnovi.NewQuery(const SQLCode: String; AParams: TParameters;
  parAutoOpen: Boolean): TADOQuery;
begin
  Result := TADOQuery.Create(DtmSisnnovi.connSisnnovi);

  try
    with Result do
    begin
      Connection:= DtmSisnnovi.connSisnnovi;
      SQL.Text := SQLCode;

      if AParams <> nil then
        Parameters.AssignValues(AParams);

      if parAutoOpen then
        open;
    end;
  except
    Result.Free;
    raise;
  end;
end;

end.
